//
//  MydeTableViewCell.m
//  day1
//
//  Created by 于跃隆 on 2020/4/3.
//  Copyright © 2020 于跃隆. All rights reserved.
//

#import "MydeTableViewCell.h"

@implementation MydeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style
             reuseIdentifier:reuseIdentifier]) {
//        self.layer.cornerRadius = 10;
//        self.layer.masksToBounds = YES;

        ViewRadius(self, KSCHEIGHT(10));
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setFrame];
    }
    return self;
}
 - (void)setFrame:(CGRect)frame{

     CGRect f = frame;
     f.origin.x = kSCRATIO(10);
     f.size.width = frame.size.width - kSCRATIO(20);
     [super setFrame:f];
}

-(void)setFrame{
    [self addSubview:self.yaoImageV];
    [self addSubview:self.yaoImageVT];
    [self addSubview:self.yaobtn];
    [self addSubview:self.TextLabel];
    [self addSubview:self.DetailLabel];
    
    
    [self.yaoImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(kSCRATIO(15));
        make.left.mas_offset(kSCRATIO(10));
        make.width.height.mas_offset(kSCRATIO(35));
        
    }];
    [self.TextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.yaoImageV).mas_equalTo(kSCRATIO(-5));
        make.left.mas_equalTo(self.yaoImageV.mas_left).mas_equalTo(kSCRATIO(45));
        
    }];
    [self.DetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.TextLabel).mas_equalTo(kSCRATIO(25));
        make.left.mas_equalTo(self.yaoImageV.mas_left).mas_offset(kSCRATIO(45));
        
    }];
    
    [self.yaoImageVT mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.TextLabel).mas_equalTo(kSCRATIO(5));
//        make.left.mas_equalTo(self.TextLabel.mas_left).mas_equalTo(kSCRATIO(50));
        make.right.mas_equalTo(self.TextLabel.mas_right).mas_equalTo(kSCRATIO(40));
        make.width.mas_offset(kSCRATIO(33));
        make.height.mas_offset(kSCRATIO(13));
        
    }];
    [self.yaobtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_offset(kSCRATIO(-20));
//        make.bottom.mas_offset(kSCRATIO(-20));
        make.top.mas_equalTo(KSCHEIGHT(15));
        make.width.mas_offset(kSCRATIO(85));
        make.height.mas_offset(kSCRATIO(30));
        
    }];
    
}
-(UIImageView *)yaoImageV{
    if (!_yaoImageV) {
        _yaoImageV = [[UIImageView alloc] init];
        _yaoImageV.image = [UIImage imageNamed:@"1"];
    }
    return _yaoImageV;
}
-(UIImageView *)yaoImageVT{
    if (!_yaoImageVT) {
        _yaoImageVT = [[UIImageView alloc] init];
        _yaoImageVT.image = [UIImage imageNamed:@"21"];
    }
    return _yaoImageVT;
}
-(UIButton *)yaobtn{
    if (!_yaobtn) {
        _yaobtn = [[UIButton alloc] init];

        CAGradientLayer *gl = [CAGradientLayer layer];
        gl.frame = CGRectMake(0,0,kSCRATIO(85),KSCHEIGHT(30));
        gl.startPoint = CGPointMake(0, 0);
        gl.endPoint = CGPointMake(1, 1);
        gl.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
        gl.locations = @[@(0.0),@(1.0)];

        [self.yaobtn.layer addSublayer:gl];
        ViewRadius(_yaobtn, kSCRATIO(15));
        [_yaobtn setTitle:@"+8888元" forState:UIControlStateNormal];
        [_yaobtn setTitleColor:ColorWhite forState:UIControlStateNormal];
//        [_yaobtn setBackgroundColor:AppThemeColor];
        _yaobtn.titleLabel.font = KMEDIUM(13);
        
        
    }
    return _yaobtn;
}
-(UILabel *)TextLabel{
    if (!_TextLabel) {
        _TextLabel = [[UILabel alloc] init];
        _TextLabel.text = @"123";
        _TextLabel.textColor = [UIColor blackColor];
        _TextLabel.font = kFONT(18);
    }
    return _TextLabel;
}
-(UILabel *)DetailLabel{
    if (!_DetailLabel) {
        _DetailLabel = [[UILabel alloc] init];
        _DetailLabel.text = @"1231321312323132313";
        _DetailLabel.font = kFONT(12);
        _DetailLabel.textColor = [UIColor lightGrayColor];
    }
    return _DetailLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
